import 'package:gin_vue_admin_web/local/constants.dart';

class OpLogParams extends PageParams {
  String? method, path;
  int? status;

  OpLogParams({
    this.method,
    this.path,
    this.status,
  });

  void reset() {
    method = null;
    path = null;
    status = null;
  }

  void setParams(Map<String, dynamic> params) {
    method = params["method"];
    path = params["path"];
    status = params["status"];
  }

  @override
  Map<String, dynamic> toPageDataMap() {
    return {
      if (method != null) 'method': method,
      if (path != null) 'path': path,
      if (status != null) 'status': status,
      'page': page,
      'pageSize': limit,
    };
  }
}

class GetApiListParams extends PageParams {
  GetApiListParams();

  @override
  Map<String, dynamic> toPageDataMap() {
    return {...super.toPageDataMap()};
  }
}

class PageParams {
  int page;
  int limit;

  PageParams(
      {this.page = Constants.startPage, this.limit = Constants.rowsPerPage});

  Map<String, dynamic> toPageDataMap() {
    return {
      'page': page,
      'pageSize': limit,
    };
  }
}

class CreateAuthorityParams {
  final int? id;
  final String roleName;

  CreateAuthorityParams({
    this.id,
    required this.roleName,
  });

  /// Converts the object to a Map.
  Map<String, dynamic> toMap() {
    return {
      if (id != null) 'id': id,
      'roleName': roleName,
    };
  }
}

class EditRoleMenuParams {
  final int roleId;
  final List<int> ids;

  EditRoleMenuParams({
    required this.roleId,
    required this.ids,
  });

  /// Converts the object to a Map.
  Map<String, dynamic> toMap() {
    return {'roleId': roleId, 'ids': ids};
  }
}

class SetUserInfoParams {
  final bool? active;
  final int? id;
  final int? roleId;
  final String? email;
  final String? phone;
  final String? username;
  final String? password;
  final String? oldPassword;
  final String? newPassword;
  final int type;

  SetUserInfoParams(
      {this.active,
      this.roleId,
      this.email,
      this.password,
      this.oldPassword,
      this.newPassword,
      this.phone,
      this.username,
      this.id,
      this.type = 0});

  /// Converts the object to a Map.
  Map<String, dynamic> toMap() {
    return {
      if (active != null) "active": active,
      if (roleId != null) "roleId": roleId,
      if (username != null) "username": username,
      if (email != null) "email": email,
      if (password != null) "password": password,
      if (phone != null) "phone": phone,
      if (newPassword != null) "newPassword": newPassword,
      if (oldPassword != null) "oldPassword": oldPassword,
      if (id != null) "id": id,
    };
  }
}

class SetFileParams {
  final int type;
  final String? name;
  final int? id;

  SetFileParams({
    this.type = 0,
    this.name,
    this.id,
  });

  /// Converts the object to a Map.
  Map<String, dynamic> toMap() {
    return {
      if (name != null) "name": name,
      if (id != null) "id": id,
    };
  }
}

class SetCronParams {
  final bool? active;
  final int? id;

  final int type;

  SetCronParams({this.active, this.id, this.type = 0});

  /// Converts the object to a Map.
  Map<String, dynamic> toMap() {
    return {
      if (active != null) "active": active,
      if (id != null) "id": id,
    };
  }
}

class GetSysDictionaryDetailListParams extends PageParams {
  int? sysDictionaryID;

  GetSysDictionaryDetailListParams({this.sysDictionaryID});

  @override
  Map<String, dynamic> toPageDataMap() {
    return {
      ...super.toPageDataMap(),
      if (sysDictionaryID != null) "sysDictionaryID": sysDictionaryID
    };
  }
}

class FindSysDictionaryDetailParams {
  int? id;
  bool? status;

  FindSysDictionaryDetailParams({
    this.id,
    this.status,
  });

  /// Converts the object to a Map.
  Map<String, dynamic> toMap() {
    return {
      "id": id,
      "status": status,
    };
  }
}

class CreateSysDictionaryParams {
  final String name;
  final String type;
  final bool status;
  final String desc;

  CreateSysDictionaryParams({
    required this.name,
    required this.type,
    required this.status,
    required this.desc,
  });

  /// Converts the object to a Map.
  Map<String, dynamic> toMap() {
    return {
      "name": name,
      "type": type,
      "status": status,
      "desc": desc,
    };
  }
}

class CreateSysDictionaryDetailParams {
  final int sysDictionaryID;
  final String label;
  final String value;
  final int sort;
  final String status;

  CreateSysDictionaryDetailParams({
    required this.sysDictionaryID,
    required this.label,
    required this.value,
    required this.sort,
    required this.status,
  });

  /// Converts the object to a Map.
  Map<String, dynamic> toMap() {
    return {
      'sysDictionaryID': sysDictionaryID,
      'label': label,
      'value': value,
      'sort': sort,
      'status': status,
    };
  }
}
